n = int(input())
l = list(map(int, input().split()))
target = int(input())
l.sort()

def dfs(ll, s, t):
    if not ll: return False
    for i,x in enumerate(ll):
        if x + s > t: continue
        elif x + s < t:
            s += x
            stack = ll[:]
            stack.pop(i)
            dfs(stack, s, t)
        else:
            return True

flag = False
for i,x in enumerate(l):
    if x == target:
        break
    else:
        flag = dfs(l[1:],x,target)
        if flag: break
if flag:
    print(1)
else:
    print(0)

class Solution(object):
    def combinationSum(self, candidates, target):
        """
        :type candidates: List[int]
        :type target: int
        :rtype: List[List[int]]
        """
        self.resList = []
        candidates = sorted(candidates)
        self.dfs(candidates,[],target,0)
        return self.resList

    def dfs(self, candidates, sublist, target, last):
        if target == 0:
            self.resList.append(sublist[:])
        if target < candidates[0]:
            return
        for n in candidates:
            if n > target:
                return
            if n < last:
                continue
            sublist.append(n)
            self.dfs(candidates,sublist,target - n, n)
            sublist.pop()